using System;
using System.Collections.Generic;
using System.Text;

namespace Eve.Data
{
    public class SchoolAgent : EveAssociation<School, int>
    {
        private int agentId;

        private Agent agent;

        public School School
        {
            get { return From; }
        }
        public int Index
        {
            get { return To; }
        }
        public Agent Agent
        {
            get
            {
                if (agent == null)
                    agent = new Agent(db, agentId);
                return agent;
            }
        }

        internal SchoolAgent(DbDataRow dr)
            : base(dr.Database, new School(dr.Database, dr["schoolID"]), dr["agentIndex"])
        {
            Fill(dr);
        }

        private void Fill(DbDataRow dr)
        {
            agentId = dr["agentId"];
        }
    }
}
